<template>
  <div>
    <van-nav-bar title="购物车" left-arrow @click-left="$router.go(-1)" />
    <div class="cart" 
    
      v-for="(item, index) in clothes" :key="item.id" >
      <Cart 
      :name="item.name" :price="item.price" :imgname="clothesImg[index].imgname"
      ></Cart>
      </div>
      <van-submit-bar :price="3050" button-text="提交订单" @submit="onSubmit">
        <van-checkbox v-model="checked">全选</van-checkbox>
      </van-submit-bar>
  </div>
</template>

<script>
import Cart from '@/components/cart.vue'
import { getClothe, getClotheImg } from '@/api/clothe'
  export default {
    data() {
      
      return {
         // 定义数组保存智能穿戴数据
            clothes: [],
            // 定义数组保存对应的图片
            clothesImg: [],
            checked: false,
      }
    },
    components:{Cart},
     methods: {
      
      onSubmit(){},
     // 获取智能穿戴信息
        async getWear () {
            const data = await getClothe()
            this.clothes = data.data.message
            console.log(this.clothes)
            
        },
        // 获取智能穿戴信息图片
        async getWearImg () {
            const data = await getClotheImg()
            console.log(data)
            this.clothesImg = data.data.message
        }
  },
   mounted () {
        this.getWear()
        this.getWearImg ()
    }
  }
</script>

<style lang="scss" scoped>
::v-deep .van-nav-bar .van-icon {
  color: black;
}
</style>